package com.ivan.model.entity.hosp;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ivan.model.entity.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * RegisterRule
 * </p>
 *
 * @author Ivan
 */
@Data
@ApiModel(description = "预约规则")
@TableName("booking_rule")
public class BookingRule extends BaseEntity {
	
	@ApiModelProperty(value = "医院编号")
	private String hoscode;

	@ApiModelProperty(value = "预约周期")
	private Integer cycle;

	@ApiModelProperty(value = "放号时间")
	private String releaseTime;

	@ApiModelProperty(value = "停挂时间")
	private String stopTime;

	@ApiModelProperty(value = "退号截止天数（如：就诊前一天为-1，当天为0）")
	private Integer quitDay;

	@ApiModelProperty(value = "退号时间")
	private String quitTime;

	@ApiModelProperty(value = "预约规则(多个规则用英文,分割)")
	private String rule;

	@ApiModelProperty(hidden = true)
	@TableField(exist = false)
	private List<String> rules;

	/**
	 *
	 * @param rule
	 */
	public void setRules(String rule) {
		if(!StringUtils.isEmpty(rule)) {
			if (rule.contains(",")) {
				this.rules = Arrays.asList(rule.split(","));
			} else {
				this.rules = Arrays.asList(rule);;
			}
		}
	}

}

